<%@ include file="header.jsp" %>
<%@ page import="com.UI" %>
<%@ page import="com.User" %>

<%
	// Check if the user is an admin, if not redirect them
	if (!theUser.isAdmin(request.getSession().getId())){
		response.sendRedirect("ruleviolations.jsp");
	}
%>
	
<script>document.getElementById("defineNewRulesButton").className += "active";</script>

<div class="page-header">
	<h1>Define New Rule</h1>
</div>

<div class="jumbotron">
	<form class="form-horizontal" role="form" method="post" action="DefineRuleServlet">
		<div class="form-group">
			<label for="inputRuleName" class="col-sm-3 control-label">Rule Name</label>
			<div class="col-sm-6">
				<% out.print(new UI().displayRuleNameInput(request)); %>
			</div>
		</div>
		<div class="form-group">
			<label for="inputDataField" class="col-sm-3 control-label">Data Field</label>
			<div class="col-sm-6">
				<select class="form-control" id="inputDataField" name="dataField">
					<% out.print(new UI().displayDataFieldsDropdown(session, request)); %>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="inputSpecification" class="col-sm-3 control-label"></label>
			<div class="col-sm-6">
				<select class="form-control" id="inputSpecification" name="specification">
					<% out.print(new UI().displaySpecificationsDropdown(session, request)); %>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="inputBoundaryType" class="col-sm-3 control-label">Must be</label>
			<div class="col-sm-6">
				<select class="form-control" id="inputBoundaryType" name="boundaryType">
					<% out.print(new UI().displayBoundaryTypesDropdown(session, request)); %>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label for="inputBoundaryCondition" class="col-sm-3 control-label"></label>
			<div class="col-sm-6">
				<% out.print(new UI().displayBoundaryConditionInput(request)); %>
			</div>
		</div>
		<div class="col-sm-offset-3 col-sm-6">
			<button type="submit" class="btn btn-default">Submit</button>
		</div>
	</form>
</div>

<%@ include file="footer.jsp" %>